home *** CD-ROM | disk | FTP | other *** search
- Path: usenet.eel.ufl.edu!warwick!bham!bhamcs!news
- From: Ian Moody <I.J.Moody-CSAI93@cs.bham.ac.uk>
- Newsgroups: comp.lang.c++
- Subject: Nasty bus error using pure virtual functions
- Date: Thu, 07 Mar 1996 01:12:41 +0000
- Organization: University of Birmingham
- Message-ID: <313E3809.67F8@cs.bham.ac.uk>
- NNTP-Posting-Host: mother.cs.bham.ac.uk
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0 (X11; I; SunOS 5.4 sun4m)
- CC: I.J.Moody-CSAI93@cs.bham.ac.uk
-
- Hi,
-
- I am getting a very nasty bus error in my code which I simply CANNOT
- get rid of. I can usually cope OK with bus errors but this has me
- completely stumped. The program is being developed on a Sun network
- as part of my university final year project and I only have
- two weeks left to sort it out....(me thinks I left things a bit late)
-
- Here is an outline of the part of my proggy concerned (please ignore
- any obvious spelling mistakes and my strange way of implementing a
- linked list {:)
-
-
- struct LinkedListStruct
- {
- void *item;
- int type;
- LinkedListStruct *next;
- };
-
- class LinkedList
- {
- protected:
- LinkedList();
- virtual int Compare(int,void*,void*) = 0;
- int Find(LinkedListStruct*,LinkedListStruct*,void*);
- int Remove(....);
- ....
- };
-
- int LinkedList::Find(LinkedListStruct *first,
- LinkedListStruct *last,
- void *data)
- {
- ...
- LinkedListStruct *current=first;
- while(current)
- {
- if(Compare(current->type,current->item,data)==0)
- {
- ...
- }
- current=current->next;
- };
- ...
- };
-
- i.e. any class which inherits LinkedList MUST provide its own
- compare function. The Find(...) function uses Compare(...) to
- see if there are any similar items already on the list. arg is
- not important.
- Now I have for example ...
-
-
- class FileLock : public LinkedList
- {
- private:
- LinkedListStruct *first;
- LinkedListStruct *last;
- int counter;
- public:
- FileLock();
- ....
- int FindLock(void*);
- };
-
-
- int FileLock::FindLock(void *stuff)
- {
- ...
- Find(first,last,stuff);
- ...
- };
-
- NOW, when I call FindLock(....)
- I get a BUS error on the line in LinkedList::Find(...) which tries
- to do the Compare(...), as far as I can tell it's somthing to do with
- the arguments I'm give it. My other theory is that its something
- to do with having pure virtual functions?
-
- This is all part of a multithreaded program, but I'm SURE that this
- has nothing to do with it because I still get the error even if I create
- some dummy variables and arguments within the LinkedList::Find(...)
- function and try to pass them to the Compare(..).
-
- I hope I haven't explained it too badly...
- Is there anywhere else I could post this as I really am getting a bit
- desperate now.
-
- thanks,
-
- Ian Moody,
-